package suites.utils {
	import org.flexunit.asserts.assertEquals;
	import org.flexunit.asserts.assertFalse;
	import org.flexunit.asserts.assertTrue;
	import org.flexunit.asserts.fail;
	import org.splink.library.utils.ObjectUtils;

	/**
	 * @author Max Kugland
	 */
	public class ObjectUtilsTest {

		[Test(description="typed clone test")]
		public function testTypedClone() : void {
			var v1 : Person = new Person();
			v1.name = "Max";			var v2 : Person = ObjectUtils.clone(v1, Person, "org.splink.library.tests.utils::Person");
			
			Person(v2);
			assertTrue(v2 is Person);
			assertEquals(v1.name, v2.name);
			assertFalse(v1 == v2);		}
		
		[Test(description="untyped clone test")]
		public function testUnypedClone() : void {
			var v1 : Person = new Person();
			v1.name = "Max";
			var v2 : Object = ObjectUtils.clone(v1);
			try {
				Person(v2);
				fail();
			} catch(e:Error) {
			}
			
			assertEquals(v1.name, v2["name"]);
			assertFalse(v1 == v2);
		}
	}
}
